package com.jlpay.openapi.demo.trans.c2b;

import com.jlpay.open.jlpay.sdk.java.model.trans.c2b.request.QrcodePayPreAuthRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.c2b.response.QrcodePayPreAuthResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class QrcodePayPreAuthService {
    private static final Logger LOGGER = LoggerFactory.getLogger(QrcodePayPreAuthService.class);

    public static void main(String[] args) {
        QrcodePayPreAuthRequest qrcodePayPreAuthRequest = buildQrcodePayPreAuthRequest();
        QrcodePayPreAuthResponse qrcodePayPreAuthResponse = JlpayOpenApiService.openMerchService()
                .post(qrcodePayPreAuthRequest, QrcodePayPreAuthResponse.class);
        LOGGER.info("扫码支付(C2B)扫码预授权响应:{}", JsonUtils.toString(qrcodePayPreAuthResponse));
    }

    private static QrcodePayPreAuthRequest buildQrcodePayPreAuthRequest() {
        QrcodePayPreAuthRequest qrcodePayPreAuthRequest = new QrcodePayPreAuthRequest();

        qrcodePayPreAuthRequest.setMchId("849584358120018");
        qrcodePayPreAuthRequest.setTermNo("60131234");
        qrcodePayPreAuthRequest.setPayType("wxpay");
        qrcodePayPreAuthRequest.setOutTradeNo("ld201911023465529");
        qrcodePayPreAuthRequest.setPaymentValidTime("10");
        qrcodePayPreAuthRequest.setBody("充值中心-会员充值");
        qrcodePayPreAuthRequest.setAttach("商城—-易拉宝10个打印纸20箱");
        qrcodePayPreAuthRequest.setTotalFee("1");
        qrcodePayPreAuthRequest.setRemark("该订单物流请走顺丰快递");
        qrcodePayPreAuthRequest.setNotifyUrl("www.baidu.com");
        qrcodePayPreAuthRequest.setOpUserId("001");
        qrcodePayPreAuthRequest.setOpShopId("GD_SZ_001");
        qrcodePayPreAuthRequest.setDeviceInfo("N50007A8890");
        qrcodePayPreAuthRequest.setMchCreateIp("123.12.12.123");
        qrcodePayPreAuthRequest.setTransAddress("深圳市南山区科技二路10号");
        qrcodePayPreAuthRequest.setAreaCode("4403");
        qrcodePayPreAuthRequest.setLongitude("116.078631");
        qrcodePayPreAuthRequest.setLatitude("39.71274");
        qrcodePayPreAuthRequest.setSubAppid("wxid_129752pfasf1671");

        return qrcodePayPreAuthRequest;
    }
}
